home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / iaca101.zip / IACAFILL.ASM < prev    next >
Assembly Source File  |  1991-11-10  |  3KB  |  136 lines

  1.     title    IACAFILL - insert string in Inter-Application Comm. Area
  2.  
  3. ; Copyright (c) 1991 by
  4. ;    Robert W. Babcock
  5. ;    WSS Division of DDC
  6. ;    4 Reeves Road
  7. ;    Bedford, MA  01730
  8. ;    USA
  9. ;    617-275-1183
  10.  
  11. ; Unlimited non-commercial use authorized.
  12.  
  13. ; This is an MS-DOS device driver which inserts its argument into the
  14. ; 16-byte Inter-application communication area at 40:f0 and then exits
  15. ; without installing.  The purpose it to enable passing information from
  16. ; CONFIG.SYS to AUTOEXEC.BAT.  A companion routine IACAREAD uses the value
  17. ; found at 40:f0 to set an environment variable.  Sample usage might be
  18.  
  19. ; in CONFIG.SYS
  20. ;    device=c:\dos\drivers\iacafill.sys TD-386
  21.  
  22. ; in AUTOEXEC.BAT
  23. ;    iacaread systype
  24. ;    if /%SYSTYPE% == /TD-386 goto td386_specific_code
  25. ;    if /%SYSTYPE% == /VANILLA goto vanilla_code
  26.  
  27. ; Note that DOS 5 upcases the argument before this routine sees it.  On the
  28. ; other hand, the Quarterdeck DEVICE command for loading device drivers in a
  29. ; window does not upcase the argument.  I have not tested how previous DOS
  30. ; versions behave.
  31.  
  32. CR    equ    13        ; carriage return
  33. LF    equ    10        ; line feed
  34.  
  35. ; MS-DOS Request header definition
  36. Request    struc
  37. Rlength    db    ?
  38. Unit    db    ?
  39. Command    db    ?
  40. Status    dw    ?
  41. Reserve    db    8 dup(?)
  42. Media    db    ?
  43. Addroff    dw    ?
  44. Addrseg    dw    ?
  45. Nameoff    dw    ?    ; also count
  46. Nameseg    dw    ?    ; also sector
  47. Request    ends
  48.  
  49. iaca    segment word
  50.  
  51. header    label word
  52.     dd    -1
  53.     dw    8000h        ; character driver
  54.     dw    offset init    ; strategy=init for this driver which does
  55.                 ; not install anything
  56.  
  57.     dw    offset interrupt
  58.     db    'DRIVER  '
  59.  
  60. ; I'm not sure why, but this entry point does get called
  61. ; even though the driver does not install itself.
  62.  
  63. interrupt proc    far
  64.     xor    ax,ax
  65.     ret
  66. interrupt    endp
  67.  
  68. init_msg:
  69.     db    CR, LF, 'IACAFILL version 1.0', CR, LF
  70.     db    '  Copyright (c) 1991 by Robert W. Babcock'
  71.     db    ' and WSS Divison of DDC', CR, LF, '$'
  72.  
  73. ; Execution starts here
  74. ; es:bx points to request header
  75.  
  76. init    proc    far
  77.     assume    cs:iaca, ds:iaca
  78.  
  79.     mov    dx, offset init_msg
  80.     mov    ah, 9
  81.     int    21h
  82.  
  83.     mov    di, bx
  84.     push    di
  85.     push    es
  86.  
  87.     mov    si, es:[di.Nameoff]    ; offset of device name in config.sys
  88.     mov    ds, es:[di.Nameseg]    ; segment of device name in config.sys
  89.  
  90. ; skip over any spaces before driver name
  91.  
  92. trim_beginning:
  93.     lodsb
  94.     cmp    al, ' '
  95.     jbe    trim_beginning
  96.  
  97. ; skip over driver name (which could have been changed)
  98.  
  99. find_driver:
  100.     lodsb
  101.     cmp    al, ' '
  102.     ja    find_driver
  103.  
  104. ; skip over any trailing spaces
  105.  
  106. trim_end:
  107.     lodsb
  108.     cmp    al, ' '
  109.     jbe    trim_end
  110.  
  111.     dec    si        ; si has been incremented past first char
  112.  
  113. ; ds:si now points to arg or CR if none
  114.  
  115.     mov    cx, 16        ; max number of chars to move
  116.     mov    ax, 40h
  117.     mov    es, ax        ; bios segment
  118.     mov    di, 0f0h    ; destination
  119. store_loop:
  120.     lodsb
  121.     cmp    al, CR
  122.     je    done
  123.     stosb
  124.     loop    store_loop
  125. done:
  126.     pop    es
  127.     pop    di
  128.     mov    byte ptr es:[di.Unit], 0    ; zero units installed
  129.     mov    word ptr es:[di.Addroff], 0    ; free memory offset = 0
  130.     mov    es:[di.Addrseg], cs        ; free memory segment
  131.     mov    word ptr es:[di.Status], 100h    ; return code = done
  132.     ret
  133. init    endp
  134. iaca    ends
  135.     end
  136.